import MUtil from 'util/mm.jsx';

const _mm = new MUtil();

class User{
    // 用户登录
    login(loginInfo){
        return _mm.request({
            type: 'post',
            url: '/manage/user/login.do',
            data: loginInfo
        });
    }
	//检查登陆的数据是否合法
	checkLoginInfo(userInfo){
     let username = $.trim(userInfo.username),
         password = $.trim(userInfo.password);
      if(typeof username !== 'string' || username.length === 0){
      	return {
      		status : false,
      		msg    : '用户名不能为空'
      	}
      }
       if(typeof password !== 'string' || password.length === 0){
      	return {
      		status : false,
      		msg    : '密码不能为空'
      	}
      }
      	return {
      		status : true,
      		msg    :  '验证成功'
      }
	}
  getUserList(pageNum){
    return _mm.request({
            type: 'post',
            url: '/manage/user/list.do',
            data : {
              pageNum : pageNum
            }
        });
  }
	logout(){
		return _mm.request({
            type: 'post',
            url: '/user/logout.do'
        });
	}
}

export default User;